package bg.btanev.eightyfour.service.pooling;

import org.apache.commons.lang.Validate;

/**
 *
 * @author B.Tanev
 *
 */
public abstract class AbstractPoolingTask implements PoolingTask {
	private static int DEFAULT_POOL_INTERVAL = 15 * 60 * 1000; // 15 minutes

	private final String taskName;
	private final long poolingInterval;

	protected AbstractPoolingTask(final String name) {
		this(name, DEFAULT_POOL_INTERVAL);
	}

	protected AbstractPoolingTask(final String name, long interval) {
		super();

		Validate.notEmpty(name);
		if (interval <= 0) {
			interval = DEFAULT_POOL_INTERVAL;
		}

		this.taskName = name;
		this.poolingInterval = interval;
	}

	@Override
	public long getPoolingInterval() {
		return this.poolingInterval;
	}

	@Override
	public String getTaskName() {
		return this.taskName;
	}
}
